<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>电子发票管理系统—注册租户</title>
<link href="../webjars/bootstrap/3.3.7-1/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="../static/css/index.css" rel="stylesheet" type="text/css">
<script src="../static/jquery-easyui-1.5.5.3/jquery.min.js"></script>
<script src="../webjars/bootstrap/3.3.7-1/js/bootstrap.js"></script>
<script src="../static/layer-v3.1.1/layer/layer.js"></script>
<script type="text/javascript" src="../static/js/index.js"></script>
<script type="text/javascript">
	function fun_tc(){
		layer.confirm("你确定退出吗？", {
			btn:['确定', '取消']
		}, function(){ 
			window.location.href="../logout1";
			layer.msg("已退出", {icon: 1});
		});
	}
	function fun(str){
		$("#name-error").html("");
		$.post('username', {username: str}, function(data){
			if(data){
				$("#name-error").html("此租户已注册");
			}
		});
	}
	function fun1(){
		$("#phone-error").html("");
	}
	function fun2(){
		$("#linkman-error").html("");
	}
	function fun3(){
		$("#username-error").html("");
	}
	function fun4(){
		$("#password-error").html("");
	}
	$(function(){
		$("#btn_1").click(function(){
			$("#gly-error").html("");
			var phone = $("#phone").val();
			var name = $("#name").val();
			var linkman = $("#linkman").val();
			var username = $("#username").val();
			var password = $("#password").val();
			var f = false;
			if(phone == "" || phone == ""){
				f = true;
				$("#phone-error").html("请输入电话");
			}
			if(name == "" || name == null){
				f = true;
				$("#name-error").html("请输入租户名称");
			}
			if(linkman == "" || linkman == null){
				f = true;
				$("#linkman-error").html("请输入联系人");
			}
			if(username == "" || username == null){
				f = true;
				$("#username-error").html("请输入管理员邮箱");
			}
			if(password == "" || password == null){
				f = true;
				$("#password-error").html("请输入管理员密码");
			}
			if(!f){
				$.post('gly', {password: password, username: username}, function(data){
					if(data){
						$.post('username', {username: name}, function(data1){
							if(!data1){
								var form = $('#myform').serialize();
								alert('注册成功！');
								window.location.href="save?"+form;
							}else{
								$("#name-error").html("此租户已注册");
							}
						});
					}else{
						$("#password-error").html("管理员账号或密码输入错误");
					}
				});
			}
		});
	});
</script>
<style type="text/css">
	#home_1{
		background: white;
		width: 90%;
		margin: 30px auto;
		padding: 20px 35px;
	}
	#mydialog tr td{
		height: 50px;
		text-align: right;
	}
	#mydialog tr td input{
		width: 200px;
	}
	.error{
		color: red;
	}
</style>
</head>
<body>
	<nav class="navbar navbar-default navbar-fixed-top" id="nav" style="margin-bottom: 0px;">
		<div class="navbar-header" style="background: red;">
			<button type="button" class="navbar-toggle" data-toggle="collapse" style="background: #F8F8F8;" data-target="#menu">
	        	<span class="sr-only">展开导航</span>
	            <span class="icon-bar"></span>
	            <span class="icon-bar"></span>
	            <span class="icon-bar"></span> 
	       </button>
			<a class="navbar-brand" id="logo" href="">电子发票管理系统</a>
		</div>
		
		<div class="collapse navbar-collapse" id="menu">
			<ul class="nav navbar-nav" id = "mytab">
				<li><a><span class="glyphicon glyphicon-list" id="dhl"></span></a></li>
			</ul>
			
			<ul class="nav navbar-nav navbar-right">
				<li><a href="../main1"><span class="glyphicon glyphicon-home"></span> 首页</a></li>
				<li class="dropdown">
					<a href="" class="dropdown-toggle" data-toggle="dropdown">
						<span class="glyphicon glyphicon-user"></span>
						<span sec:authorize="hasRole('ROLE_SYSTEM')"> 开发者 </span>
						<span sec:authorize="!hasRole('ROLE_SYSTEM')" sec:authentication="principal.name"></span>
						<span class="caret"></span>
					</a>
					<ul class="dropdown-menu pull-right">
						<li onclick="fun_tc()"><a><span class="glyphicon glyphicon-log-out"></span>&emsp;安全退出</a></li>
					</ul>
				</li>
				<li><a></a></li>
				<li><a></a></li>
			</ul>
		</div>
	</nav>
	
	<div id="dhl1">
    	<p sec:authorize="hasRole('ROLE_ADMIN')" class="aaa" style="background: #000;"><a style="color: white;">注册租户</a></p>
    	<p sec:authorize="hasRole('ROLE_ADMIN')" class="aaa"><a href="../lesseeAdmin/update">修改密码</a></p>
    	<p sec:authorize="hasRole('ROLE_ADMIN')" class="aaa"><a href="../user/all">用户管理</a></p>
    	<p sec:authorize="hasRole('ROLE_ADMIN')" class="aaa"><a href="../invoice/findById">电子发票管理</a></p>
    	<p sec:authorize="hasRole('ROLE_ADMIN')" class="aaa"><a href="../accredit/findById">软件授权信息</a></p>
	</div>
	
	<div id="home">
		<div id="home_1">
			<ul class="breadcrumb">
				<li><span class="glyphicon glyphicon-home"></span>&emsp;当前位置：</li>
				<li><a class="active">注册租户</a></li>
			</ul>
			
			<div class=" col-md-offset-3" style="margin-top: 20px; width: 75%;">
				<form action="save" id="myform" method="post" class="form-horizontal" >
					<div class="form-group">
						<label for="user" class="col-md-2 control-label" >电话</label>
						<div class="col-md-4">
							<input type="text" class="form-control" name="phone" onchange="fun1();" id = "phone" placeholder="电话">
						</div>
						<div class="col-md-12"><label id="phone-error" class="error col-lg-offset-3" for="phone"></label></div>
					</div>
					<div class="form-group">
						<label for="pass" class="col-md-2 control-label">租户名称</label>
						<div class="col-md-4">
							<input type="text" class="form-control" onchange="fun(this.value);" name="name" id = "name" placeholder="租户名称">
						</div>
						<div class="col-md-12"><label id="name-error" class="error col-lg-offset-3" for="name"></label></div>
					</div>
					<div class="form-group">
						<label for="pass" class="col-md-2 control-label">联系人</label>
						<div class="col-md-4">
							<input type="text" class="form-control" onchange="fun2();" name="linkman" id = "linkman" placeholder="联系人">
						</div>
						<div class="col-md-12"><label id="linkman-error" class="error col-lg-offset-3" for="linkman"></label></div>
					</div>
					<div class="form-group">
						<label for="pass" class="col-md-2 control-label">管理员电子邮箱</label>
						<div class="col-md-4">
							<input type="text" class="form-control" name="username" onchange="fun3();" id = "username" placeholder="管理员电子邮箱">
						</div>
						<div class="col-md-12"><label id="username-error" class="error col-lg-offset-3" for="username"></label></div>
					</div>
					<div class="form-group">
						<label for="pass" class="col-md-2 control-label">管理员密码</label>
						<div class="col-md-4">
							<input type="password" class="form-control" name="password" onchange="fun4();" id = "password" placeholder="管理员密码">
						</div>
						<div class="col-md-12"><label id="password-error" class="error col-lg-offset-3" for="password"></label></div>
					</div>
					<div class="form-group">
						<div class="col-md-4 col-md-offset-2">
							<button type="button" id = "btn_1" style="width: 160px;" class="btn btn-info">确定</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</body>
</html>